import lib.logging.Level;
import lib.logging.Logger;

import javax.swing.*;
import java.awt.*;

public class App {

    /**
     * @param args
     */
    public static void main(String[] args) {
        //Default log level for the program
        Logger.instance.setLogLevel(Level.INFO);
        CommandLine cmd = new CommandLine();
        try {
            cmd.Parse(args);
        } catch (Exception e) {
            Logger.instance.error(e.getMessage());
        }
        if (cmd.isGui()) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    try {
                        UIManager.setLookAndFeel(UIManager
                                .getSystemLookAndFeelClassName());
                        MainWindow window = new MainWindow();
                        window.setVisible(true);
                    } catch (Exception e) {
                        Logger.instance.error(Logger.stack2String(e));
                    }
                }
            });
        } else {
            cmd.CheckUpdate();
            cmd.executeArgs();
        }
    }
}
